/** lib **/
import { ref } from 'vue'
import { useStore } from 'vuex'

export default () => {
  // useStore
  const store = useStore()
  const primaryColor: String | null = window.localStorage.getItem('primaryColor')
  const colorValue = ref(primaryColor ? primaryColor : '#504657')
  const handleChangeColor = (e: string) => {
    store
      .dispatch('handleModifyVars', colorValue.value)
      .then((res) => {
        console.log('res', res)
        console.log(store.state.primaryColor)
        console.log(colorValue)
      })
      .catch((err) => {
        console.log('err', err.toString())
      })
  }
  // @returns
  return {
    colorValue,
    handleChangeColor,
  }
}
